package com.ljx.hzit.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

	@Bean
	public Docket docketApiInfo(){
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.groupName("api组")
				.select()
				.paths(Predicates.and(PathSelectors.regex("/api/.*")))
				.build();
	}
	@Bean
	public Docket docketAdminInfo(){
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(adminInfo())
				.groupName("admin组")
				.select()
				.paths(Predicates.and(PathSelectors.regex("/admin/.*")))
				.build();
	}
	/**
	 * 1. 定制后端开发接口信息
	 * @return
	 */
	private ApiInfo adminInfo() {
		return new ApiInfoBuilder()
				.version("1.0.0")
				.title("广告管理系统-API文档")
				.description("本文档描述了广告管理员系统接口")
				.contact(new Contact("广告后台管理员","http://hzitxx.com","1924647332@qq.com"))
				.build();
	}
	/**
	 * 1. 定制前端开发接口信息
	 * @return
	 */
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.version("1.0.0")
				.title("后台管理系统-API文档")
				.description("本文档描述了管理系统接口")
				.contact(new Contact("合众后台普通用户","http://hzitxx.com","23232441@qq.com"))
				.build();
	}
}
